<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>待办清单</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
            background-color: #f5f5f5;
            color: #333;
            overflow-x: hidden;
        }

        .status-bar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 8px 20px;
            background-color: #fff;
            font-size: 14px;
            font-weight: 500;
        }

        .time {
            font-weight: 600;
        }

        .status-icons {
            display: flex;
            align-items: center;
            gap: 4px;
        }

        .header {
            background-color: #fff;
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
        }

        .user-section {
            display: flex;
            align-items: center;
            gap: 10px;
            margin-bottom: 15px;
        }

        .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            background-color: #ddd;
            display: flex;
            align-items: center;
            justify-content: center;
            position: relative;
        }

        .avatar::after {
            content: '';
            position: absolute;
            bottom: 0;
            right: 0;
            width: 12px;
            height: 12px;
            background-color: #ff9500;
            border-radius: 50%;
            border: 2px solid #fff;
        }

        .login-text {
            color: #ff6b6b;
            font-size: 16px;
        }

        .top-icons {
            display: flex;
            gap: 20px;
            margin-left: auto;
        }

        .icon {
            width: 24px;
            height: 24px;
            opacity: 0.6;
        }

        .search-bar {
            background-color: #f0f0f0;
            border-radius: 20px;
            padding: 10px 15px;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .search-icon {
            width: 16px;
            height: 16px;
            opacity: 0.5;
        }

        .search-input {
            border: none;
            background: none;
            outline: none;
            flex: 1;
            font-size: 14px;
            color: #999;
        }

        .main-content {
            padding: 0 20px;
        }

        /* 视图切换按钮 */
        .view-toggle {
            display: flex;
            background-color: #f0f0f0;
            border-radius: 8px;
            margin: 15px 20px;
            padding: 4px;
        }

        .view-toggle-btn {
            flex: 1;
            padding: 8px 16px;
            border: none;
            background: none;
            border-radius: 6px;
            font-size: 14px;
            color: #666;
            cursor: pointer;
            transition: all 0.2s;
        }

        .view-toggle-btn.active {
            background-color: #fff;
            color: #333;
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }

        /* 日历视图样式 */
        .calendar-view {
            background-color: #fff;
            margin: 0 20px;
            border-radius: 12px;
            padding: 20px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        }

        .calendar-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .calendar-title {
            font-size: 18px;
            font-weight: 600;
            color: #333;
        }

        .calendar-nav {
            display: flex;
            gap: 10px;
        }

        .calendar-nav-btn {
            width: 32px;
            height: 32px;
            border: none;
            background-color: #f0f0f0;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            font-size: 16px;
            color: #666;
        }

        .calendar-nav-btn:hover {
            background-color: #e0e0e0;
        }

        .calendar-weekdays {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 8px;
            margin-bottom: 10px;
        }

        .calendar-weekday {
            text-align: center;
            font-size: 12px;
            color: #999;
            padding: 8px 0;
            font-weight: 500;
        }

        .calendar-days {
            display: grid;
            grid-template-columns: repeat(7, 1fr);
            gap: 8px;
        }

        .calendar-day {
            aspect-ratio: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 8px;
            font-size: 14px;
            cursor: pointer;
            position: relative;
            transition: all 0.2s;
        }

        .calendar-day:hover {
            background-color: #f0f0f0;
        }

        .calendar-day.today {
            background-color: #ff6b6b;
            color: white;
            font-weight: 600;
        }

        .calendar-day.selected {
            background-color: #007AFF;
            color: white;
        }

        .calendar-day.other-month {
            color: #ccc;
        }

        .calendar-day.has-tasks::after {
            content: '';
            position: absolute;
            bottom: 4px;
            left: 50%;
            transform: translateX(-50%);
            width: 4px;
            height: 4px;
            background-color: #ff6b6b;
            border-radius: 50%;
        }

        .calendar-day.today.has-tasks::after {
            background-color: white;
        }

        /* 任务分类列表 */
        .category-list {
            display: none;
        }

        .category-list.show {
            display: block;
        }

        .category-item {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 0;
            border-bottom: 1px solid #f0f0f0;
        }

        .category-left {
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .category-icon {
            width: 20px;
            height: 20px;
            border-radius: 4px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 12px;
        }

        .today-icon {
            background-color: #4CAF50;
            color: white;
        }

        .tomorrow-icon {
            background-color: #FF9800;
            color: white;
        }

        .week-icon {
            background-color: #9C27B0;
            color: white;
        }

        .planned-icon {
            background-color: #2196F3;
            color: white;
        }

        .schedule-icon {
            background-color: #00BCD4;
            color: white;
        }

        .completed-icon {
            background-color: #607D8B;
            color: white;
        }

        .tasks-icon {
            background-color: #3F51B5;
            color: white;
        }

        .category-text {
            font-size: 16px;
            color: #333;
        }

        .category-right {
            display: flex;
            align-items: center;
            gap: 8px;
            color: #999;
            font-size: 14px;
        }

        .add-task {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 15px 0;
            color: #ff6b6b;
            font-size: 16px;
            border: none;
            background: none;
            width: 100%;
            text-align: left;
        }

        .add-icon {
            font-size: 20px;
            font-weight: 300;
        }

        .bottom-nav {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background-color: #fff;
            border-top: 1px solid #eee;
            display: flex;
            justify-content: space-around;
            padding: 10px 0;
        }

        .nav-item {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 4px;
            color: #999;
            font-size: 12px;
            text-decoration: none;
        }

        .nav-item.active {
            color: #ff6b6b;
        }

        .nav-icon {
            width: 24px;
            height: 24px;
            border-radius: 50%;
            background-color: #333;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 14px;
            font-weight: bold;
        }

        .floating-button {
            position: fixed;
            bottom: 80px;
            right: 20px;
            width: 56px;
            height: 56px;
            border-radius: 50%;
            background-color: #ff6b6b;
            color: white;
            border: none;
            font-size: 24px;
            box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
            cursor: pointer;
        }

        /* 详情页面样式 */
        .detail-page {
            display: none;
            background-color: #fff;
            min-height: 100vh;
        }

        .detail-header {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 15px 20px;
            border-bottom: 1px solid #eee;
        }

        .back-btn {
            font-size: 18px;
            color: #333;
            background: none;
            border: none;
        }

        .detail-title {
            font-size: 18px;
            font-weight: 600;
        }

        .more-btn {
            font-size: 18px;
            color: #999;
            background: none;
            border: none;
        }

        .stats-section {
            padding: 20px;
            background-color: #f8f8f8;
        }

        .stats-grid {
            display: grid;
            grid-template-columns: 1fr 1fr 1fr 1fr;
            gap: 20px;
            text-align: center;
        }

        .stat-item {
            display: flex;
            flex-direction: column;
            gap: 5px;
        }

        .stat-number {
            font-size: 24px;
            font-weight: bold;
            color: #ff6b6b;
        }

        .stat-label {
            font-size: 12px;
            color: #999;
        }

        .add-task-section {
            padding: 20px;
            border-bottom: 1px solid #eee;
        }

        .add-task-btn {
            display: flex;
            align-items: center;
            gap: 10px;
            color: #999;
            font-size: 16px;
            background: none;
            border: none;
            width: 100%;
            text-align: left;
        }

        .task-list {
            padding: 0 20px;
        }

        .task-item {
            display: flex;
            align-items: center;
            gap: 15px;
            padding: 15px 0;
            border-bottom: 1px solid #f0f0f0;
        }

        .task-checkbox {
            width: 20px;
            height: 20px;
            border: 2px solid #ddd;
            border-radius: 50%;
            cursor: pointer;
            transition: all 0.3s ease;
            position: relative;
        }

        .task-checkbox:hover {
            border-color: #007AFF;
        }

        .task-checkbox.checked {
            background-color: #007AFF;
            border-color: #007AFF;
        }

        .task-checkbox.checked::after {
            content: '✓';
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            color: white;
            font-size: 12px;
            font-weight: bold;
        }

        .task-text {
            flex: 1;
            font-size: 16px;
            color: #333;
        }

        .task-arrow {
            color: #ff6b6b;
            font-size: 16px;
        }

        .show-completed {
            text-align: center;
            padding: 20px;
            color: #999;
            font-size: 14px;
        }

        .page-indicator {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            background-color: rgba(0, 0, 0, 0.7);
            color: white;
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 14px;
        }

        /* 模态框样式 */
        .modal {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.5);
            z-index: 1000;
        }

        .modal-content {
            position: absolute;
            bottom: 0;
            left: 0;
            right: 0;
            background-color: white;
            border-radius: 20px 20px 0 0;
            padding: 20px;
            max-height: 80vh;
            overflow-y: auto;
        }

        .modal-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 20px;
        }

        .modal-title {
            font-size: 18px;
            font-weight: 600;
        }

        .close-btn {
            background: none;
            border: none;
            font-size: 24px;
            color: #999;
            cursor: pointer;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-label {
            display: block;
            margin-bottom: 5px;
            font-size: 14px;
            color: #333;
        }

        .form-input {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            outline: none;
        }

        .form-input:focus {
            border-color: #ff6b6b;
        }

        .form-textarea {
            width: 100%;
            padding: 12px;
            border: 1px solid #ddd;
            border-radius: 8px;
            font-size: 16px;
            outline: none;
            resize: vertical;
            min-height: 80px;
        }

        .form-textarea:focus {
            border-color: #ff6b6b;
        }

        .btn-group {
            display: flex;
            gap: 10px;
            margin-top: 20px;
        }

        .btn {
            flex: 1;
            padding: 12px;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            cursor: pointer;
        }

        .btn-primary {
            background-color: #ff6b6b;
            color: white;
        }

        .btn-secondary {
            background-color: #f0f0f0;
            color: #333;
        }

        .timer-display {
            font-size: 24px;
            font-weight: bold;
            color: #ff6b6b;
            text-align: center;
            margin: 10px 0;
        }

        .timer-controls {
            display: flex;
            justify-content: center;
            gap: 10px;
            margin: 10px 0;
        }

        .timer-btn {
            padding: 8px 16px;
            border: none;
            border-radius: 20px;
            background-color: #ff6b6b;
            color: white;
            cursor: pointer;
        }

        .search-results {
            background-color: white;
            border-radius: 8px;
            margin-top: 10px;
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            display: none;
        }

        .search-item {
            padding: 12px 15px;
            border-bottom: 1px solid #f0f0f0;
            cursor: pointer;
        }

        .search-item:hover {
            background-color: #f8f8f8;
        }

        .search-item:last-child {
            border-bottom: none;
        }

        .notification {
            position: fixed;
            top: 50px;
            left: 20px;
            right: 20px;
            background-color: #4CAF50;
            color: white;
            padding: 12px 16px;
            border-radius: 8px;
            z-index: 1001;
            display: none;
        }
    </style>
</head>
<body>
    <!-- 主页面 -->
    <div id="main-page">
        <!-- 状态栏 -->
        <div class="status-bar">
            <span class="time">17:30</span>
            <div class="status-icons">
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>🔋</span>
                <span>75</span>
            </div>
        </div>

        <!-- 头部 -->
        <div class="header">
            <div class="user-section">
                <div class="avatar">👤</div>
                <span class="login-text">登录/注册</span>
                <div class="top-icons">
                    <div class="icon">👥</div>
                    <div class="icon">🌱</div>
                    <div class="icon">🏆</div>
                    <div class="icon">📊</div>
                </div>
            </div>
            <div class="search-bar">
                <div class="search-icon">🔍</div>
                <input type="text" class="search-input" placeholder="搜索" oninput="handleSearch(this.value)">
            </div>
        </div>

        <!-- 视图切换按钮 -->
        <div class="view-toggle">
            <button class="view-toggle-btn active" onclick="switchView('calendar')">📅 日历</button>
            <button class="view-toggle-btn" onclick="switchView('list')">📋 列表</button>
        </div>

        <!-- 日历视图 -->
        <div id="calendar-view" class="calendar-view">
            <div class="calendar-header">
                <h2 class="calendar-title" id="calendar-title">2024年7月</h2>
                <div class="calendar-nav">
                    <button class="calendar-nav-btn" onclick="changeMonth(-1)">‹</button>
                    <button class="calendar-nav-btn" onclick="changeMonth(1)">›</button>
                </div>
            </div>
            
            <div class="calendar-weekdays">
                <div class="calendar-weekday">日</div>
                <div class="calendar-weekday">一</div>
                <div class="calendar-weekday">二</div>
                <div class="calendar-weekday">三</div>
                <div class="calendar-weekday">四</div>
                <div class="calendar-weekday">五</div>
                <div class="calendar-weekday">六</div>
            </div>
            
            <div class="calendar-days" id="calendar-days">
                <!-- 日历日期将通过JavaScript动态生成 -->
            </div>
        </div>

        <!-- 主要内容 -->
        <div class="main-content">
            <!-- 任务分类列表 -->
            <div id="category-list" class="category-list">
                <div class="category-item" onclick="showDetailPage('今天')">
                    <div class="category-left">
                        <div class="category-icon today-icon">☀️</div>
                        <span class="category-text">今天</span>
                    </div>
                    <div class="category-right">
                        <span>1h 15m</span>
                        <span>5</span>
                    </div>
                </div>

                <div class="category-item" onclick="showDetailPage('明天')">
                    <div class="category-left">
                        <div class="category-icon tomorrow-icon">🌅</div>
                        <span class="category-text">明天</span>
                    </div>
                    <div class="category-right">
                        <span>0m</span>
                        <span>0</span>
                    </div>
                </div>

                <div class="category-item" onclick="showDetailPage('本周')">
                    <div class="category-left">
                        <div class="category-icon week-icon">📅</div>
                        <span class="category-text">本周</span>
                    </div>
                    <div class="category-right">
                        <span>1h 15m</span>
                        <span>5</span>
                    </div>
                </div>

                <div class="category-item" onclick="showDetailPage('所有任务')">
                    <div class="category-left">
                        <div class="category-icon planned-icon">📋</div>
                        <span class="category-text">所有任务</span>
                    </div>
                    <div class="category-right">
                        <span>1h 15m</span>
                        <span>5</span>
                    </div>
                </div>

                <div class="category-item">
                    <div class="category-left">
                        <div class="category-icon schedule-icon">📆</div>
                        <span class="category-text">日程</span>
                    </div>
                    <div class="category-right">
                        <span></span>
                    </div>
                </div>

                <div class="category-item">
                    <div class="category-left">
                        <div class="category-icon completed-icon">✅</div>
                        <span class="category-text">已完成</span>
                    </div>
                    <div class="category-right">
                        <span></span>
                    </div>
                </div>

                <div class="category-item" onclick="showDetailPage('任务')">
                    <div class="category-left">
                        <div class="category-icon tasks-icon">📝</div>
                        <span class="category-text">任务</span>
                    </div>
                    <div class="category-right">
                        <span>1h 15m</span>
                        <span>5</span>
                    </div>
                </div>

                <button class="add-task" onclick="showCreateListModal()">
                    <span class="add-icon">+</span>
                    <span>创建清单</span>
                </button>
            </div>
        </div>

        <!-- 底部导航 -->
        <div class="bottom-nav">
            <a href="#" class="nav-item active">
                <div class="nav-icon">25</div>
                <span>今天</span>
            </a>
            <a href="#" class="nav-item">
                <div class="nav-icon">📅</div>
                <span>预览</span>
            </a>
            <a href="#" class="nav-item">
                <div class="nav-icon">🔍</div>
                <span>搜索</span>
            </a>
            <a href="#" class="nav-item">
                <div class="nav-icon">☰</div>
                <span>浏览</span>
            </a>
        </div>

        <!-- 悬浮按钮 -->
        <button class="floating-button" onclick="showAddTaskModal()">+</button>
    </div>

    <!-- 详情页面 -->
    <div id="detail-page" class="detail-page">
        <!-- 状态栏 -->
        <div class="status-bar">
            <span class="time">17:30</span>
            <div class="status-icons">
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>📶</span>
                <span>🔋</span>
                <span>74</span>
            </div>
        </div>

        <!-- 详情头部 -->
        <div class="detail-header">
            <button class="back-btn" onclick="showMainPage()">‹</button>
            <span class="detail-title" id="detail-title">本周</span>
            <button class="more-btn">⋯</button>
        </div>

        <!-- 统计区域 -->
        <div class="stats-section">
            <div class="stats-grid">
                <div class="stat-item">
                    <span class="stat-number">01:15</span>
                    <span class="stat-label">预计时间</span>
                </div>
                <div class="stat-item">
                    <span class="stat-number">5</span>
                    <span class="stat-label">待完成任务</span>
                </div>
                <div class="stat-item">
                    <span class="stat-number">00:00</span>
                    <span class="stat-label">已专注时间</span>
                </div>
                <div class="stat-item">
                    <span class="stat-number">0</span>
                    <span class="stat-label">已完成任务</span>
                </div>
            </div>
        </div>

        <!-- 添加任务 -->
        <div class="add-task-section">
            <button class="add-task-btn" onclick="showAddTaskModal()">
                <span>+</span>
                <span>添加任务...</span>
            </button>
        </div>

        <!-- 任务列表 -->
        <div class="task-list">
            <div style="padding: 10px 0; color: #999; font-size: 14px;">今天 · 1小时15分钟</div>
            
            <div class="task-item">
                <div class="task-checkbox"></div>
                <span class="task-text">点击右侧播放按钮开始计时</span>
                <span class="task-arrow" onclick="showTimerModal('点击右侧播放按钮开始计时')">▶</span>
            </div>

            <div class="task-item">
                <div class="task-checkbox"></div>
                <span class="task-text">点击左侧圆圈完成任务</span>
                <span class="task-arrow" onclick="showTimerModal('点击左侧圆圈完成任务')">▶</span>
            </div>

            <div class="task-item">
                <div class="task-checkbox"></div>
                <span class="task-text">向左划查看更多操作</span>
                <span class="task-arrow" onclick="showTimerModal('向左划查看更多操作')">▶</span>
            </div>

            <div class="task-item">
                <div class="task-checkbox"></div>
                <span class="task-text">计时后请抵御所有干扰，保持专注！</span>
                <span class="task-arrow" onclick="showTimerModal('计时后请抵御所有干扰，保持专注！')">▶</span>
            </div>

            <div class="task-item">
                <div class="task-checkbox"></div>
                <span class="task-text">点击下方\"显示已完成任务\"按钮显示已完成任务</span>
                <span class="task-arrow" onclick="showTimerModal('点击下方显示已完成任务按钮显示已完成任务')">▶</span>
            </div>
        </div>

        <!-- 显示已完成任务 -->
        <div class="show-completed" onclick="toggleCompletedTasks()">
            <span id="show-completed-text">显示已完成任务 ▼</span>
        </div>

        <!-- 已完成任务列表 -->
        <div id="completed-tasks" style="display: none; padding: 0 20px;"></div>

        <!-- 页面指示器 -->
        <div class="page-indicator">25</div>
    </div>

    <!-- 添加任务模态框 -->
    <div id="add-task-modal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title">添加新任务</h3>
                <button class="close-btn" onclick="closeModal('add-task-modal')">&times;</button>
            </div>
            <form onsubmit="addNewTask(event)">
                <div class="form-group">
                    <label class="form-label">任务标题</label>
                    <input type="text" class="form-input" id="task-title" placeholder="输入任务标题" required>
                </div>
                <div class="form-group">
                    <label class="form-label">任务描述</label>
                    <textarea class="form-textarea" id="task-description" placeholder="输入任务描述（可选）"></textarea>
                </div>
                <div class="form-group">
                    <label class="form-label">预计时间（分钟）</label>
                    <input type="number" class="form-input" id="task-duration" placeholder="25" min="1" max="480">
                </div>
                <div class="form-group">
                    <label class="form-label">优先级</label>
                    <select class="form-input" id="task-priority">
                        <option value="low">低</option>
                        <option value="medium" selected>中</option>
                        <option value="high">高</option>
                    </select>
                </div>
                <div class="btn-group">
                    <button type="button" class="btn btn-secondary" onclick="closeModal('add-task-modal')">取消</button>
                    <button type="submit" class="btn btn-primary">添加任务</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 创建清单模态框 -->
    <div id="create-list-modal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title">创建新清单</h3>
                <button class="close-btn" onclick="closeModal('create-list-modal')">&times;</button>
            </div>
            <form onsubmit="createNewList(event)">
                <div class="form-group">
                    <label class="form-label">清单名称</label>
                    <input type="text" class="form-input" id="list-name" placeholder="输入清单名称" required>
                </div>
                <div class="form-group">
                    <label class="form-label">清单图标</label>
                    <select class="form-input" id="list-icon">
                        <option value="📝">📝 任务</option>
                        <option value="💼">💼 工作</option>
                        <option value="🏠">🏠 家庭</option>
                        <option value="🎯">🎯 目标</option>
                        <option value="📚">📚 学习</option>
                        <option value="💡">💡 想法</option>
                        <option value="🛒">🛒 购物</option>
                        <option value="✈️">✈️ 旅行</option>
                    </select>
                </div>
                <div class="form-group">
                    <label class="form-label">清单颜色</label>
                    <select class="form-input" id="list-color">
                        <option value="#ff6b6b">红色</option>
                        <option value="#4CAF50">绿色</option>
                        <option value="#2196F3">蓝色</option>
                        <option value="#FF9800">橙色</option>
                        <option value="#9C27B0">紫色</option>
                        <option value="#00BCD4">青色</option>
                    </select>
                </div>
                <div class="btn-group">
                    <button type="button" class="btn btn-secondary" onclick="closeModal('create-list-modal')">取消</button>
                    <button type="submit" class="btn btn-primary">创建清单</button>
                </div>
            </form>
        </div>
    </div>

    <!-- 任务计时器模态框 -->
    <div id="timer-modal" class="modal">
        <div class="modal-content">
            <div class="modal-header">
                <h3 class="modal-title" id="timer-task-title">专注计时</h3>
                <button class="close-btn" onclick="closeModal('timer-modal')">&times;</button>
            </div>
            <div class="timer-display" id="timer-display">25:00</div>
            <div class="timer-controls">
                <button class="timer-btn" id="timer-start" onclick="startTimer()">开始</button>
                <button class="timer-btn" id="timer-pause" onclick="pauseTimer()" style="display:none;">暂停</button>
                <button class="timer-btn" onclick="resetTimer()">重置</button>
            </div>
            <div style="text-align: center; margin-top: 20px; color: #666;">
                <p>保持专注，抵御干扰！</p>
            </div>
        </div>
    </div>

    <!-- 搜索结果 -->
    <div id="search-results" class="search-results">
        <div class="search-item">搜索结果将在这里显示...</div>
    </div>

    <!-- 通知 -->
    <div id="notification" class="notification"></div>

    <script>
        // 全局变量
        let tasks = JSON.parse(localStorage.getItem('tasks')) || [];
        let lists = JSON.parse(localStorage.getItem('lists')) || [];
        let timerInterval = null;
        let timerSeconds = 0;
        let isTimerRunning = false;
        let currentTask = null;

        // 页面导航
        function showDetailPage(title) {
            document.getElementById('main-page').style.display = 'none';
            document.getElementById('detail-page').style.display = 'block';
            document.getElementById('detail-title').textContent = title;
            loadTasksForCategory(title);
        }

        function showMainPage() {
            document.getElementById('main-page').style.display = 'block';
            document.getElementById('detail-page').style.display = 'none';
        }

        // 模态框控制
        function showAddTaskModal() {
            document.getElementById('add-task-modal').style.display = 'block';
        }

        function showCreateListModal() {
            document.getElementById('create-list-modal').style.display = 'block';
        }

        function showTimerModal(taskTitle) {
            document.getElementById('timer-modal').style.display = 'block';
            document.getElementById('timer-task-title').textContent = taskTitle || '专注计时';
            resetTimer();
        }

        function closeModal(modalId) {
            document.getElementById(modalId).style.display = 'none';
            // 清空表单
            const forms = document.querySelectorAll(`#${modalId} form`);
            forms.forEach(form => form.reset());
        }

        // 添加新任务
        function addNewTask(event) {
            event.preventDefault();
            
            const title = document.getElementById('task-title').value;
            const description = document.getElementById('task-description').value;
            const duration = parseInt(document.getElementById('task-duration').value) || 25;
            const priority = document.getElementById('task-priority').value;
            
            const newTask = {
                id: Date.now(),
                title: title,
                description: description,
                duration: duration,
                priority: priority,
                completed: false,
                category: document.getElementById('detail-title').textContent || '今天',
                createdAt: new Date().toISOString()
            };
            
            tasks.push(newTask);
            localStorage.setItem('tasks', JSON.stringify(tasks));
            
            closeModal('add-task-modal');
            showNotification('任务添加成功！');
            
            // 如果在详情页面，刷新任务列表
            if (document.getElementById('detail-page').style.display === 'block') {
                loadTasksForCategory(document.getElementById('detail-title').textContent);
            }
            
            updateTaskCounts();
        }

        // 创建新清单
        function createNewList(event) {
            event.preventDefault();
            
            const name = document.getElementById('list-name').value;
            const icon = document.getElementById('list-icon').value;
            const color = document.getElementById('list-color').value;
            
            const newList = {
                id: Date.now(),
                name: name,
                icon: icon,
                color: color,
                createdAt: new Date().toISOString()
            };
            
            lists.push(newList);
            localStorage.setItem('lists', JSON.stringify(lists));
            
            closeModal('create-list-modal');
            showNotification('清单创建成功！');
            
            // 添加到主页面
            addListToMainPage(newList);
        }

        // 在主页面添加新清单
        function addListToMainPage(list) {
            const mainContent = document.querySelector('.main-content');
            const addTaskButton = document.querySelector('.add-task');
            
            const listItem = document.createElement('div');
            listItem.className = 'category-item';
            listItem.onclick = () => showDetailPage(list.name);
            
            listItem.innerHTML = `
                <div class="category-left">
                    <div class="category-icon" style="background-color: ${list.color}; color: white;">${list.icon}</div>
                    <span class="category-text">${list.name}</span>
                </div>
                <div class="category-right">
                    <span>0m</span>
                    <span>0</span>
                </div>
            `;
            
            mainContent.insertBefore(listItem, addTaskButton);
        }

        // 加载分类任务
        function loadTasksForCategory(category) {
            const categoryTasks = tasks.filter(task => task.category === category && !task.completed);
            const taskList = document.querySelector('.task-list');
            
            // 清空现有任务（保留标题）
            const taskItems = taskList.querySelectorAll('.task-item');
            taskItems.forEach(item => item.remove());
            
            // 添加任务
            categoryTasks.forEach(task => {
                const taskItem = document.createElement('div');
                taskItem.className = 'task-item';
                taskItem.innerHTML = `
                    <div class="task-checkbox" onclick="toggleTaskComplete(${task.id})"></div>
                    <span class="task-text">${task.title}</span>
                    <span class="task-arrow" onclick="showTimerModal('${task.title}')">▶</span>
                `;
                taskList.appendChild(taskItem);
            });
            
            updateStats(categoryTasks);
        }

        // 更新统计信息
        function updateStats(tasks) {
            const totalDuration = tasks.reduce((sum, task) => sum + task.duration, 0);
            const hours = Math.floor(totalDuration / 60);
            const minutes = totalDuration % 60;
            
            const statNumbers = document.querySelectorAll('.stat-number');
            if (statNumbers.length >= 4) {
                statNumbers[0].textContent = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;
                statNumbers[1].textContent = tasks.length.toString();
                // 已专注时间和已完成任务保持原样或从localStorage获取
            }
        }

        // 切换任务完成状态
        function toggleTaskComplete(taskId) {
            const task = tasks.find(t => t.id === taskId);
            if (task) {
                task.completed = !task.completed;
                
                if (task.completed) {
                    // 记录完成时间
                    const now = new Date();
                    task.completedTime = now.toLocaleTimeString('zh-CN', { hour: '2-digit', minute: '2-digit' });
                    showNotification('任务已完成！');
                } else {
                    // 清除完成时间
                    task.completedTime = null;
                    showNotification('任务已恢复');
                }
                
                localStorage.setItem('tasks', JSON.stringify(tasks));
                
                // 重新加载当前分类的任务
                if (document.getElementById('detail-page').style.display === 'block') {
                    loadTasksForCategory(document.getElementById('detail-title').textContent);
                }
                
                updateTaskCounts();
                
                // 如果已完成任务列表正在显示，更新它
                const completedTasksDiv = document.getElementById('completed-tasks');
                if (completedTasksDiv.style.display === 'block') {
                    toggleCompletedTasks();
                    toggleCompletedTasks(); // 调用两次来刷新显示
                }
            }
        }

        // 计时器功能
        function startTimer() {
            if (!isTimerRunning) {
                isTimerRunning = true;
                document.getElementById('timer-start').style.display = 'none';
                document.getElementById('timer-pause').style.display = 'inline-block';
                
                timerInterval = setInterval(() => {
                    if (timerSeconds > 0) {
                        timerSeconds--;
                        updateTimerDisplay();
                    } else {
                        // 计时结束
                        clearInterval(timerInterval);
                        isTimerRunning = false;
                        showNotification('专注时间结束！休息一下吧 🎉');
                        resetTimer();
                    }
                }, 1000);
            }
        }

        function pauseTimer() {
            if (isTimerRunning) {
                clearInterval(timerInterval);
                isTimerRunning = false;
                document.getElementById('timer-start').style.display = 'inline-block';
                document.getElementById('timer-pause').style.display = 'none';
            }
        }

        function resetTimer() {
            clearInterval(timerInterval);
            isTimerRunning = false;
            timerSeconds = 25 * 60; // 25分钟
            updateTimerDisplay();
            document.getElementById('timer-start').style.display = 'inline-block';
            document.getElementById('timer-pause').style.display = 'none';
        }

        function updateTimerDisplay() {
            const minutes = Math.floor(timerSeconds / 60);
            const seconds = timerSeconds % 60;
            document.getElementById('timer-display').textContent = 
                `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
        }

        // 搜索功能
        function handleSearch(query) {
            const searchResults = document.getElementById('search-results');
            
            if (query.trim() === '') {
                searchResults.style.display = 'none';
                return;
            }
            
            const filteredTasks = tasks.filter(task => 
                task.title.toLowerCase().includes(query.toLowerCase()) ||
                task.description.toLowerCase().includes(query.toLowerCase())
            );
            
            searchResults.innerHTML = '';
            
            if (filteredTasks.length === 0) {
                searchResults.innerHTML = '<div class="search-item">未找到相关任务</div>';
            } else {
                filteredTasks.forEach(task => {
                    const item = document.createElement('div');
                    item.className = 'search-item';
                    item.innerHTML = `
                        <div><strong>${task.title}</strong></div>
                        <div style="font-size: 12px; color: #999;">${task.category} • ${task.duration}分钟</div>
                    `;
                    item.onclick = () => {
                        showDetailPage(task.category);
                        searchResults.style.display = 'none';
                        document.querySelector('.search-input').value = '';
                    };
                    searchResults.appendChild(item);
                });
            }
            
            searchResults.style.display = 'block';
        }

        // 底部导航
        function switchTab(tabName) {
            // 移除所有active类
            document.querySelectorAll('.nav-item').forEach(item => {
                item.classList.remove('active');
            });
            
            // 添加active类到当前标签
            event.target.closest('.nav-item').classList.add('active');
            
            // 根据标签执行相应操作
            switch(tabName) {
                case 'today':
                    showMainPage();
                    break;
                case 'preview':
                    showNotification('预览功能开发中...');
                    break;
                case 'search':
                    document.querySelector('.search-input').focus();
                    break;
                case 'browse':
                    showNotification('浏览功能开发中...');
                    break;
            }
        }

        // 显示通知
        function showNotification(message) {
            const notification = document.getElementById('notification');
            notification.textContent = message;
            notification.style.display = 'block';
            setTimeout(() => {
                notification.style.display = 'none';
            }, 3000);
        }

        // 切换已完成任务显示
        function toggleCompletedTasks() {
            const completedTasksDiv = document.getElementById('completed-tasks');
            const showCompletedText = document.getElementById('show-completed-text');
            
            if (completedTasksDiv.style.display === 'none') {
                // 显示已完成任务
                const completedTasks = tasks.filter(task => task.completed);
                completedTasksDiv.innerHTML = '';
                
                if (completedTasks.length === 0) {
                    completedTasksDiv.innerHTML = '<div style="text-align: center; color: #999; padding: 20px;">暂无已完成任务</div>';
                } else {
                    completedTasks.forEach(task => {
                        const taskElement = document.createElement('div');
                        taskElement.className = 'task-item completed';
                        taskElement.innerHTML = `
                            <div class="task-checkbox checked"></div>
                            <span class="task-text" style="text-decoration: line-through; color: #999;">${task.text}</span>
                            <span class="task-time" style="color: #999;">${task.completedTime || ''}</span>
                        `;
                        completedTasksDiv.appendChild(taskElement);
                    });
                }
                
                completedTasksDiv.style.display = 'block';
                showCompletedText.textContent = '隐藏已完成任务 ▲';
            } else {
                // 隐藏已完成任务
                completedTasksDiv.style.display = 'none';
                showCompletedText.textContent = '显示已完成任务 ▼';
            }
        }

        // 更新任务计数
        function updateTaskCounts() {
            const categories = ['今天', '明天', '本周', '所有任务', '任务'];
            
            categories.forEach(category => {
                const categoryTasks = tasks.filter(task => task.category === category && !task.completed);
                const totalDuration = categoryTasks.reduce((sum, task) => sum + task.duration, 0);
                const hours = Math.floor(totalDuration / 60);
                const minutes = totalDuration % 60;
                
                // 更新主页面的计数显示
                const categoryItems = document.querySelectorAll('.category-item');
                categoryItems.forEach(item => {
                    const text = item.querySelector('.category-text').textContent;
                    if (text === category) {
                        const rightSection = item.querySelector('.category-right');
                        const spans = rightSection.querySelectorAll('span');
                        if (spans.length >= 2) {
                            spans[0].textContent = totalDuration > 0 ? 
                                `${hours}h ${minutes}m` : '0m';
                            spans[1].textContent = categoryTasks.length.toString();
                        }
                    }
                });
            });
        }

        // 更新时间
        function updateTime() {
            const now = new Date();
            const timeString = now.getHours().toString().padStart(2, '0') + ':' + 
                             now.getMinutes().toString().padStart(2, '0');
            document.querySelectorAll('.time').forEach(el => {
                el.textContent = timeString;
            });
        }

        // 点击模态框外部关闭
        document.addEventListener('click', function(e) {
            if (e.target.classList.contains('modal')) {
                e.target.style.display = 'none';
            }
            
            // 任务复选框点击事件
            if (e.target.classList.contains('task-checkbox')) {
                e.target.style.backgroundColor = e.target.style.backgroundColor ? '' : '#4CAF50';
                e.target.style.borderColor = e.target.style.borderColor ? '#ddd' : '#4CAF50';
                e.target.innerHTML = e.target.innerHTML ? '' : '✓';
                e.target.style.color = 'white';
            }
            
            // 点击搜索结果外部关闭搜索结果
            if (!e.target.closest('.search-bar') && !e.target.closest('#search-results')) {
                document.getElementById('search-results').style.display = 'none';
            }
        });

        // 底部导航点击事件
        document.querySelectorAll('.nav-item').forEach(item => {
            item.addEventListener('click', function(e) {
                e.preventDefault();
                const tabName = this.querySelector('span').textContent;
                switchTab(tabName);
            });
        });

        // 视图切换功能
        function switchView(viewType) {
            const calendarView = document.getElementById('calendar-view');
            const categoryList = document.getElementById('category-list');
            const toggleBtns = document.querySelectorAll('.view-toggle-btn');
            
            // 移除所有按钮的活动状态
            toggleBtns.forEach(btn => btn.classList.remove('active'));
            
            if (viewType === 'calendar') {
                calendarView.style.display = 'block';
                categoryList.style.display = 'none';
                document.querySelector('[onclick="switchView(\'calendar\')"]').classList.add('active');
            } else {
                calendarView.style.display = 'none';
                categoryList.style.display = 'block';
                document.querySelector('[onclick="switchView(\'list\')"]').classList.add('active');
            }
        }

        // 当前日期
        let currentDate = new Date();
        
        // 生成日历
        function generateCalendar(year, month) {
            const calendarDays = document.getElementById('calendar-days');
            const calendarTitle = document.getElementById('calendar-title');
            
            // 更新标题
            const monthNames = ['1月', '2月', '3月', '4月', '5月', '6月', 
                              '7月', '8月', '9月', '10月', '11月', '12月'];
            calendarTitle.textContent = `${year}年${monthNames[month]}`;
            
            // 清空日历
            calendarDays.innerHTML = '';
            
            // 获取当月第一天和最后一天
            const firstDay = new Date(year, month, 1);
            const lastDay = new Date(year, month + 1, 0);
            const startDate = new Date(firstDay);
            startDate.setDate(startDate.getDate() - firstDay.getDay());
            
            // 生成6周的日期
            for (let week = 0; week < 6; week++) {
                for (let day = 0; day < 7; day++) {
                    const date = new Date(startDate);
                    date.setDate(startDate.getDate() + week * 7 + day);
                    
                    const dayElement = document.createElement('div');
                    dayElement.className = 'calendar-day';
                    dayElement.textContent = date.getDate();
                    
                    // 添加样式类
                    if (date.getMonth() !== month) {
                        dayElement.classList.add('other-month');
                    }
                    
                    if (date.toDateString() === new Date().toDateString()) {
                        dayElement.classList.add('today');
                    }
                    
                    // 模拟一些日期有任务
                    if (Math.random() > 0.7) {
                        dayElement.classList.add('has-tasks');
                    }
                    
                    dayElement.onclick = () => selectDate(date);
                    calendarDays.appendChild(dayElement);
                }
            }
        }
        
        // 选择日期
        function selectDate(date) {
            // 移除之前选中的日期
            document.querySelectorAll('.calendar-day.selected').forEach(day => {
                day.classList.remove('selected');
            });
            
            // 选中当前日期
            event.target.classList.add('selected');
            
            console.log('选中日期:', date.toLocaleDateString());
        }
        
        // 切换月份
        function changeMonth(direction) {
            currentDate.setMonth(currentDate.getMonth() + direction);
            generateCalendar(currentDate.getFullYear(), currentDate.getMonth());
        }

        // 初始化
        document.addEventListener('DOMContentLoaded', function() {
            updateTime();
            updateTaskCounts();
            resetTimer();
            
            // 初始化日历
            generateCalendar(currentDate.getFullYear(), currentDate.getMonth());
            
            // 默认显示日历视图
            switchView('calendar');
            
            // 每分钟更新时间
            setInterval(updateTime, 60000);
        });

        // 页面加载完成后执行初始化
        if (document.readyState === 'loading') {
            document.addEventListener('DOMContentLoaded', function() {
                updateTaskCounts();
                // 初始化日历
                generateCalendar(currentDate.getFullYear(), currentDate.getMonth());
                // 默认显示日历视图
                switchView('calendar');
            });
        } else {
            updateTaskCounts();
            // 初始化日历
            generateCalendar(currentDate.getFullYear(), currentDate.getMonth());
            // 默认显示日历视图
            switchView('calendar');
        }
    </script>
</body>
</html>